package cn.i7baozh.alibaba.provider;

import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.assertj.core.util.Lists;

import java.io.File;
import java.nio.charset.Charset;
import java.util.Collections;
import java.util.Iterator;

/**
 * @author zhangbaoqi532
 * @date 2025/4/7
 */
public class Test {

    public static void main(String[] args) {
        String s = FileUtil.readString(new File("C:\\Users\\baoqizhang\\Desktop\\address-city.json"), Charset.defaultCharset());
        JSONArray jsonArray = JSONArray.parseArray(s);
        JSONArray target = new JSONArray();
        for (int i = 0; i < jsonArray.size(); i++) {
            JSONObject pro = jsonArray.getJSONObject(i);
            JSONArray cities = pro.getJSONArray("children");
            for (int j = 0; j < cities.size(); j++) {
                JSONObject city = cities.getJSONObject(j);
                city.put("children", Lists.newArrayList());
            }
//            System.out.println(pro);
            target.add(pro);
        }
        System.out.println(target);
    }

}
